package view;

import java.awt.event.ActionListener;

import util.resources.ResourceManager;
import javax.swing.*;

/**
 * Creates the Menu bar at the top of the Viewer window. Utilizes 
 * property files to dynamically generate the menu.
 * 
 * Modified from MenuBar.java (Picassa Team 6)
 * 
 * @author wesleybrown
 * @author Ethan Yong-Hui Goh
 *
 */
public class MenuBar {

	public static JMenuBar createMenuBar (ResourceManager resources, String[] menuEntries, ActionListener listener)
	{
		JMenuBar menu = new JMenuBar();

		// Create main menu items and associated submenu items
		for (String entry : menuEntries)
		{
			JMenu menuEntry = new JMenu(entry);
			String[] menuEntryItems = resources.getStringArray(entry);
			MenuItem.addJMenuItems(menuEntry, menuEntryItems, listener);
			menu.add(menuEntry);
		}
		return menu;
	}
}
